<?php 
class Admin_Form_Slide extends Zend_Form{
    
   public function init(){
        $this->setMethod("post");
		$this->setName("SlideForm");
        $this->setAttrib('autocomplete', 'off');	        	
        $this->setEnctype(Zend_Form::ENCTYPE_MULTIPART);
        $this->setElementDecorators(array(
            array('ViewHelper'),
            array('Errors'),
            array('Description'),
            array('Label', array('separator'=>' ')),
            array('HtmlTag', array('tag' => 'li', 'class'=>'element-group')),
        ));

        
        
        
        
        $image = new Zend_Form_Element_File('image');
        $image->setLabel('Hình ảnh')
              ->setDestination(APPLICATION_PATH ."/../public/upload")
              ->setRequired(true)
              //->setMaxFileSize(10240000) // limits the filesize on the client side
              ->setDescription('Nhấn vào nút browse để upload hình ảnh');
        $image->addValidator('Count', false, 1);                // ensure only 1 file
        $image->addValidator('Size', false, 10240000);            // limit to 10 meg
        $image->addValidator('Extension', false, 'jpg,jpeg,png,gif');// only JPEG, PNG, 
        
        $link = new Zend_Form_Element_Text('link');
        $link->setLabel('Link')
             ->setRequired(true)
             ->addValidator('NotEmpty',true,array('messages' => 'Không được chống!'));
        $link->setAttrib('size', '45');
        
        $title = new Zend_Form_Element_Text('title');
        $title->setLabel('Tên slide');
           
        $title->setAttrib('size', '45');
        
        $title_vn = new Zend_Form_Element_Text('title_en');
        $title_vn->setLabel('Tên slide English');
           
        $title_vn->setAttrib('size', '45');
        
        $title_chi = new Zend_Form_Element_Text('title_china');
        $title_chi->setLabel('Tên slide China');
           
        $title_chi->setAttrib('size', '45');
        
        
		$model   = new Vina_Model_Products();
        $data       = $model->fetchListToArray("1=1");
        foreach($data as $valueCat):
        $optionCat[$valueCat['id']] = $valueCat['name'];
        endforeach;
		
		$optionCat[''] = "Chọn Sản phẩm!";
        
        $category = new Zend_Form_Element_Select('product_id');
        $category->setLabel('Sản phẩm')
              ->setMultiOptions($optionCat);
        $category->setValue('');          
        
		
		$active = new Zend_Form_Element_Checkbox('status');
        $active->setLabel('Trạng thái')
              ->addFilter('StringToLower');
		
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Save');
        $submit->class = "bt-save";
        
        $this->addElements(array($title, $title_vn, $title_chi, $image, $category, $link, $active,
        $submit));                                           
    }  
}
